import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class AQS {

    public static void main(String[] args) {
        ReentrantLock reentrantLock=new ReentrantLock();

        Condition condition=reentrantLock.newCondition();

        Thread thread = new Thread() {
            @Override
            public void run() {
                System.out.println("11111111111");
                reentrantLock.lock();
                System.out.println("222222222222222");
                try {
                    condition.await();
                    System.out.println("333333333333333333333333");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                reentrantLock.unlock();


            }
        };

        thread.setName("number 11");

        thread.start();

        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        Thread thread1 = new Thread() {
            @Override
            public void run() {
                System.out.println("444444444444444444444");
                reentrantLock.lock();
                System.out.println("55555555555555555555555555");
                condition.signal();
                System.out.println("66666666666666666666");
                reentrantLock.unlock();


            }
        };
        thread1.setName("number 22");

        thread1.start();



    }


}




